package com.sunwayworld.basemodule.samplemanage.location.resource.impl;

import com.alibaba.fastjson.JSONObject;
import com.sunwayworld.basemodule.samplemanage.location.bean.LimsLocationBean;
import com.sunwayworld.basemodule.samplemanage.location.bean.LimsLocationBoardBean;
import com.sunwayworld.basemodule.samplemanage.location.bean.LocationDTO;
import com.sunwayworld.basemodule.samplemanage.location.resource.LimsLocationResource;
import com.sunwayworld.basemodule.samplemanage.location.service.LimsLocationService;
import com.sunwayworld.basemodule.samplemanage.location.validators.LimsLocationDeleteValidator;
import com.sunwayworld.framework.log.annotation.Log;
import com.sunwayworld.framework.log.annotation.LogModule;
import com.sunwayworld.framework.log.annotation.LogType;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;
import com.sunwayworld.framework.spring.annotation.GikamBean;
import com.sunwayworld.framework.validator.data.annotation.ValidateDataWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@LogModule("位置管理")
@RestController
@GikamBean
public class LimsLocationResourceImpl implements LimsLocationResource {

    @Autowired
    private LimsLocationService limsLocationService;

    @Override
    public LimsLocationService getService() {
        return limsLocationService;
    }

    @Log(value = "新增位置管理", type = LogType.INSERT)
    @Override
    @RequestMapping(method = RequestMethod.POST)
    public Long insert(RestJsonWrapperBean wrapper) {
        return getService().insert(wrapper);
    }

    @Log(value = "删除冰箱", type = LogType.DELETE)
    @Override
    @ValidateDataWith(LimsLocationDeleteValidator.class)
    public void deleteByGroup(String group) {
        getService().deleteByGroup(group);
    }

    @Log(value = "添加板子", type = LogType.INSERT)
    @Override
    public void saveBoards(RestJsonWrapperBean wrapperBean) {
        getService().saveBoards(wrapperBean);
    }

    @Log(value = "删除板子", type = LogType.DELETE)
    @Override
    public void removeBoards(RestJsonWrapperBean wrapperBean) {
        getService().removeBoards(wrapperBean);
    }

    @Log(value = "追加位置", type = LogType.DELETE)
    @Override
    public Boolean appendLocations(RestJsonWrapperBean wrapper) {
        return getService().appendLocations(wrapper);
    }

    // 可视化接口


    @Override
    @Log(value = "查询树",type = LogType.SELECT)
    public List<LocationDTO> selectTreeList(LimsLocationBean locationBean) {
        return getService().selectTree(locationBean);
    }

    @Override
    @Log(value = "下拉",type = LogType.SELECT)
    public List<Map<String,Object>> staticData(String codeCategoryId) {
        return getService().staticData(codeCategoryId);
    }

    @Override
    @Log(value = "查询", type = LogType.SELECT)
    public List<LimsLocationBean> queriesStorage(LimsLocationBean locationBean) {
        return getService().queriesStorage(locationBean);
    }

    @Override
    @Log(value = "新增设备",type = LogType.INSERT)
    public Long insertStorage(LimsLocationBean locationBean) {
        return getService().insertStorage(locationBean);
    }

    @Override
    @Log(value = "保存层")
    public LimsLocationBean saveLayer(LimsLocationBean locationBean) {
        return getService().saveLayer(locationBean);
    }

    @Override
    @Log(value = "添加层",type = LogType.INSERT)
    public Long addLayer(LimsLocationBean locationBean) {
        return getService().addLayer(locationBean);
    }

    @Override
    @Log(value = "编辑设备",type = LogType.SELECT)
    public List<LimsLocationBean> editStorage(LimsLocationBean locationBean) {
        return getService().editStorage(locationBean);
    }

    @Override
    @Log(value = "刪除",type = LogType.DELETE)
    public JSONObject delStorage(LimsLocationBean locationBean) {
        return getService().delStorage(locationBean);
    }

    @Override
    @Log(value = "删除子层",type = LogType.DELETE)
    public JSONObject delLayerChild(LimsLocationBean storageLocationBean) {
        return getService().delLayerChild(storageLocationBean.getId());
    }

    @Override
    @Log(value = "添加冻存盒",type = LogType.INSERT)
    public Long addBox(List<LimsLocationBean> locationBeans) {
        return getService().addBox(locationBeans);
    }

    @Override
    @Log(value = "添加板子",type = LogType.UPDATE)
    public void saveBoards(LimsLocationBoardBean locationBoardBean) {
        getService().saveBoards(locationBoardBean);
    }

    @Override
    @Log(value = "移除板子",type = LogType.UPDATE)
    public void removeBoards(LimsLocationBoardBean locationBoardBean) {
        getService().removeBoards(locationBoardBean);
    }

    @Override
    @Log(value = "移动板子",type = LogType.UPDATE)
    public void moveBoard(LimsLocationBoardBean locationBoardBean) {
        getService().moveBoard(locationBoardBean);
    }

    @Override
    @Log(value = "保存设备",type = LogType.UPDATE)
    public LimsLocationBean save(Long id, LimsLocationBean locationBean) {
        return getService().save(id, locationBean);
    }

    @Override
    @Log(value = "保存盒子",type = LogType.UPDATE)
    public LimsLocationBean editBox(Long id, LimsLocationBean locationBean) {
        return getService().editBox(locationBean);
    }

    @Override
    @Log(value = "查询板子",type = LogType.SELECT)
    public List<LimsLocationBoardBean> selectBoardList() {
        return getService().selectBoardList();
    }

    @Override
    public JSONObject validatorCode(LimsLocationBean locationBean) {
        return getService().validatorCode(locationBean);
    }

    @Override
    @Log(value = "国际化",type = LogType.SELECT)
    public JSONObject selectI18Message(){
        return getService().selectI18Message();
    }

    @Override
    @Log(value = "冰箱盒子添加区")
    public Long addArea(List<LimsLocationBean> locationBeans) {
        return getService().addArea(locationBeans);
    }

    @Override
    @Log(value = "冰箱下层级删除")
    public JSONObject newDelStorage(LimsLocationBean locationBean) {
        return getService().newDelStorage(locationBean);
    }

    @Override
    @Log(value = "区添加板子")
    public void newSaveBoards(LimsLocationBoardBean locationBoardBean) {
        getService().newSaveBoards(locationBoardBean);
    }

    @Override
    @Log(value = "区移除板子")
    public void newRemoveBoards(LimsLocationBoardBean locationBoardBean) {
        getService().newRemoveBoards(locationBoardBean);
    }

    @Override
    @Log(value = "区移动板子")
    public void newMoveBoard(LimsLocationBoardBean locationBoardBean) {
        getService().newMoveBoard(locationBoardBean);
    }

    @Override
    @Log("加载区和板子")
    public List<LimsLocationBean> newQueriesStorage(LimsLocationBean locationBean) {
        return getService().newQueriesStorage(locationBean);
    }

    @Override
    @Log("盒子下区号校验")
    public JSONObject validatorAreaCode(LimsLocationBean locationBean) {
        return getService().validatorAreaCode(locationBean);
    }

    @Override
    @Log("可视化库位分配设备下拉")
    public List<Map<String, Object>> kshStorageSelectable() {
        return getService().kshStorageSelectable();
    }
}
